import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale

fun formatTime(time: Long, pattern: String): String {
    return SimpleDateFormat(pattern, Locale.getDefault()).format(Date(time))
}

fun String.toLong(pattern: String): Long {
    return SimpleDateFormat(pattern, Locale.getDefault()).parse(this)?.time
        ?: throw IllegalArgumentException("Invalid date format")
}